#pragma once
#ifndef SDEF_LEVEL
#define SDEF_LEVEL

#include <SypX/SypX.h>
#include "Instance.h"
#include "Instances.h"
#include "Actor.h"
#include "Graph.h"

namespace SheepDefence
{
	class Instance;
	class Actor;
	class Graph;
	class WolfInstance;
	class DogInstance;
	class ObstacleInstance;
	class SheepInstance;

	enum LevelState
	{
		BRIEFING,
		INPROGRESS,
		GAMEOVER,
		WIN
	};

	enum Breed
	{
		TERRIER,
		COLLIE,
		GREYHOUND
	};

	class Level 
	{
	public:

		float timer_1, timer_10, timer_25;

		// Winning/Losing conditions
		int countdown, wolfCount, win, sheepCount, lose, score, stars, min, max;
		int numWolves, numSheep;
		SypX::Mesh* backgroundMesh, * clockMesh;
		SypX::MeshInstance* background, * clock;
		SypX::String brief;
		SypX::TextBox* briefBox;		
		
		void updateLevelState();
		LevelState state;
		float stateAge;

		// Dog used
		Breed character;

		// Actors
		std::vector<Actor*> actors;

		// Instances
		std::vector<Instance*> instances;
		DogInstance* dog;
		std::vector<WolfInstance*> wolves;
		std::vector<SheepInstance*> sheep;
		std::vector<ObstacleInstance*> obstacles;

		// Environment
		Graph* environment;

		SypX::Font* font;
		
		// Default constructor
		Level();

		virtual ~Level();

		// Load level
		Level(SypX::Font* f, const SypX::String&, Breed breed);

		// User input
		WolfInstance* acquireTarget(float x, float y);
		void move(float x, float y);

		// Advance
		virtual void advance(float time);

		// Draw
		virtual void draw();

		// Act
		void act(float time);
		void changeState(LevelState);
	};
}

#endif